package com.gurid.service.edu.controller.api;

import com.gurid.common.base.result.R;
import com.gurid.service.edu.entity.Teacher;
import com.gurid.service.edu.service.TeacherService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Tag(name = "ApiTeacherController", description = "讲师")
//@CrossOrigin
@RestController
@RequestMapping("/api/edu/teacher")
public class ApiTeacherController {

    @Autowired
    private TeacherService teacherService;

    @Operation(summary = "讲师列表", description = "获取所有讲师")
    @GetMapping("list")
    public R listAll() {
        List<Teacher> list = teacherService.list();
        return R.ok().data("items", list);
    }

    @Operation(summary = "讲师信息", description = "根据讲师id获取讲师信息和所有授课")
    @GetMapping("get/{id}")
    public R getById(
            @Parameter(description = "讲师id", required = true)
            @PathVariable String id) {
        Map<String, Object> map = teacherService.selectTeacherInfoById(id);
        return R.ok().data(map);
    }
}
